<?php

/*
 * Created on Dec 7, 2013
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class User_model extends CI_Model {

	public function __construct() {
		$this->load->database();
	}
	
	public function get_user_byemail($email){
  		$query = $this->db->get_where('tb_user', array('email' => $email));
  		return $query->row_array();
	}
	
	public function login($email, $password){
		$query = $this->db->get_where('tb_user', array('email' => $email, 'userpwd' => $password));
  		return $query->row_array();
	}
	
	public function get_user($id){
		$query = $this->db->get_where('tb_user', array('id' => $id));
  		return $query->row_array();
	}
	
	public function user_insert($arr){
//		echo '-----------';
//		var_dump($arr);
//		echo '-----------';
		$this->db->insert('tb_user', $arr);
	}
	
	public function user_update($id, $arr){
		$this->db-where('id', $id);
		$this->db->update('tb_user', $arr);
	}
	
	public function user_delete($id){
		$this->db->where('id', $id);
		$this->db->delete('tb_user');
	}
}

